﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;

namespace HCQ2_Model.VR.Params
{
    /// <summary>
    ///  规格模型
    /// </summary>
    public class VRSpecModel
    {
        /// <summary>
        ///  主键规格id
        /// </summary>
        public int specID { get; set; }
        /// <summary>
        ///  商品id
        /// </summary>
        [Required]
        [RegularExpression("^([1-9][0-9]*)$", ErrorMessage = "请输入商品id")]//大于0正则表达式
        public int fileId { get; set; }
        /// <summary>
        ///  规格名称
        /// </summary>
        [Required(ErrorMessage = "规格名称不能为空")]
        public string specName { get; set; }
        /// <summary>
        ///  是否影响价格
        /// </summary>
        [Required(ErrorMessage = "是否影响价格不能为空")]
        public int specMoney { get; set; }
        /// <summary>
        ///  类型
        /// </summary>
        [Required(ErrorMessage = "类型不能为空")]
        public string specType { get; set; }
        /// <summary>
        ///  子规格列表
        /// </summary>
        [Required(ErrorMessage = "子规格列表不能为空")]
        public List<VRSpecChildModel> optionList { get; set; }

        /// <summary>
        /// 转实体
        /// </summary>
        /// <returns></returns>
        public T_VRDDSpecMain toEntity()
        {
            return new T_VRDDSpecMain
            {
                fileId = this.fileId,
                specName = this.specName,
                specMoney = this.specMoney > 0 ? true : false,
                specType = this.specType
            };
        }
    }
    /// <summary>
    ///  子规格列表
    /// </summary>
    public class VRSpecChildModel
    {
        /// <summary>
        ///  子规格id
        /// </summary>
        public int optionID { get; set; }
        /// <summary>
        ///  子规格名称
        /// </summary>
        public string optionName { get; set; }
        /// <summary>
        ///  是否更新附件【0：不更新、1：更新】
        /// </summary>
        public int isEdit { get; set; }
        /// <summary>
        ///  图片id
        /// </summary>
        public string imageCode { get; set; }
    }
}